package com.lyc.platform.message.core.message;

import com.lyc.platform.message.core.message.device.DeviceOfflineMessage;
import com.lyc.platform.message.core.message.device.DeviceOnlineMessage;
import lombok.AllArgsConstructor;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

/**
 * 设备消息的类型
 *
 * @author liangyucheng
 */
@AllArgsConstructor
public enum MessageType {
    //设备上线
    ON_LINE(DeviceOnlineMessage::new),

    //设备离线
    OFF_LINE(DeviceOfflineMessage::new),

    ;


    private static final Map<String, MessageType> mapping;

    static {
        mapping = new HashMap<>();
        for (MessageType value : values()) {
            mapping.put(value.name().toLowerCase(), value);
            mapping.put(value.name().toUpperCase(), value);
        }
    }

    Supplier<? extends Message> newInstance;


}
